home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / bin / warp / next / WidgetBrowser.m < prev   
Text File  |  1993-05-22  |  2KB  |  102 lines

  1.  
  2. #import <stdio.h>
  3. #import <string.h>
  4. #import "point3.h"
  5. #import "api.h"
  6. #import "WidgetBrowser.h"
  7.  
  8. @implementation WidgetBrowser
  9. ;
  10. static id browserID, matrixID, selfID;
  11.  
  12. - init
  13. {
  14.   [super init];
  15.   matrix = [[Matrix alloc] init];
  16.   return self;
  17. }
  18.  
  19. - awakeFromNib
  20. {
  21.   browserID = browser;
  22.   matrixID = matrix;
  23.   selfID = self;
  24.   valid = 0;
  25.   return self;
  26. }
  27.  
  28. - (BOOL)browser:sender columnIsValid:(int)column
  29. {
  30.   return valid;
  31. }
  32.  
  33. - (int)browser:sender fillMatrix:theMatrix inColumn:(int)column
  34. {
  35.   id cell;
  36.   int i, rows, cols;
  37.   [matrix getNumRows:&rows numCols:&cols];
  38.  
  39.   [theMatrix renewRows:rows cols:1];
  40.   for (i = 0; i < rows; i++) {
  41.     cell = [theMatrix cellAt:i:0];
  42.     [cell takeStringValueFrom:[matrix cellAt:i:0]];
  43.     [cell setTag:i];
  44.     [cell setLoaded:YES];
  45.     [cell setLeaf:YES];
  46.   }
  47.  
  48.   valid = 1;
  49.  
  50.   return rows;
  51.  
  52. - update
  53. {
  54.   valid = 0;
  55.   [browser validateVisibleColumns];
  56.   return self;
  57. }
  58.  
  59. void uiAddWidget(const char *name, int index) {
  60.   [matrixID insertRowAt:index];
  61.   uiSetWidgetName(name, index);
  62. }
  63.  
  64. void uiSetSelectedWidget(int index) {
  65.   [[browserID matrixInColumn:0] selectCellAt:index:0];
  66.   [selfID update];
  67. }
  68.  
  69. int uiGetSelectedWidget() {
  70.   return [[browserID matrixInColumn:0] selectedRow];
  71. }
  72.  
  73. void uiSetWidgetName(const char *name, int index) {
  74.   id cell;
  75.  
  76.   cell = [matrixID cellAt:index:0];
  77.   [cell setStringValue:name];
  78.   [selfID update];
  79. }
  80.  
  81. const char *uiGetWidgetName(int index) {
  82.   return [[matrixID cellAt:index:0] stringValue];
  83. }
  84.  
  85. int uiWidgetIndex(const char *name) {
  86.   int i, cols, rows;
  87.  
  88.   [matrixID getNumRows:&rows numCols:&cols];
  89.   for (i = 0; i < rows; i++) 
  90.     if (!strcmp([[matrixID cellAt:i:0] stringValue], name)) return i;
  91.   return -1;
  92. }
  93.   
  94. void uiDeleteWidget(int index) {
  95.   [matrixID removeRowAt:index andFree:YES];
  96.   [matrixID sizeToCells];
  97.   [selfID update];
  98. }
  99.  
  100. @end
  101.